]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/network: Only list wifi networks that can be activated
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 7 Jun 2021 16:28:32 +0000 (18:28 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 16 Jul 2021 22:21:12 +0000 (22:21 +0000)
Setting up a connection for an Enterprise WPA(2) encrypted wireless
network requires Settings. That's not available when windows are
disabled via the session mode, so filter out affected entries.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1874>

js/ui/status/network.js

index 6e7878d20cc08c5fea90200b07338490c1271553..3a1d47aa1cad79b841a3ba34f8dad714e986f82b 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported NMApplet */
-const { Clutter, Gio, GLib, GObject, NM, St } = imports.gi;
+const { Clutter, Gio, GLib, GObject, Meta, NM, St } = imports.gi;
 const Signals = imports.signals;
 
 const Animation = imports.ui.animation;
@@ -816,6 +816,11 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
             GLib.source_remove(this._scanTimeoutId);
             this._scanTimeoutId = 0;
         }
+
+        if (this._syncVisibilityId) {
+            Meta.later_remove(this._syncVisibilityId);
+            this._syncVisibilityId = 0;
+        }
     }
 
     _onScanTimeout() {
@@ -1149,9 +1154,32 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
             this._itemBox.insert_child_at_index(network.item, newPos);
         }
 
+        this._queueSyncItemVisibility();
         this._syncView();
     }
 
+    _queueSyncItemVisibility() {
+        if (this._syncVisibilityId)
+            return;
+
+        this._syncVisibilityId = Meta.later_add(
+            Meta.LaterType.BEFORE_REDRAW,
+            () => {
+                const { hasWindows } = Main.sessionMode;
+                const { WPA2_ENT, WPA_ENT } = NMAccessPointSecurity;
+
+                for (const network of this._networks) {
+                    const [firstAp] = network.accessPoints;
+                    network.item.visible =
+                        hasWindows ||
+                        network.connections.length > 0 ||
+                        (firstAp._secType !== WPA2_ENT && firstAp._secType !== WPA_ENT);
+                }
+                this._syncVisibilityId = 0;
+                return GLib.SOURCE_REMOVE;
+            });
+    }
+
     _accessPointRemoved(device, accessPoint) {
         let res = this._findExistingNetwork(accessPoint);
 
@@ -1200,6 +1228,7 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
     _createNetworkItem(network) {
         network.item = new NMWirelessDialogItem(network);
         network.item.setActive(network == this._selectedNetwork);
+        network.item.hide();
         network.item.connect('selected', () => {
             Util.ensureActorVisibleInScrollView(this._scrollView, network.item);
             this._selectNetwork(network);